package com.tbsoft.ehr.service.serviceCustomer;

import java.util.List;

import com.tbsoft.ehr.dao.serviceCustomer.ServiceCustomerDao;
import com.tbsoft.ehr.dao.staffFile.StaffFileDao;
import com.tbsoft.ehr.model.ServiceCustomer;

public class ServiceCustomerServiceImpl implements ServiceCustomerService {

	private ServiceCustomerDao serviceCustomerDao;
	private StaffFileDao staffFileDao;
	public ServiceCustomerDao getServiceCustomerDao() {
		return serviceCustomerDao;
	}

	public void setServiceCustomerDao(ServiceCustomerDao serviceCustomerDao) {
		this.serviceCustomerDao = serviceCustomerDao;
	}

	public StaffFileDao getStaffFileDao() {
		return staffFileDao;
	}

	public void setStaffFileDao(StaffFileDao staffFileDao) {
		this.staffFileDao = staffFileDao;
	}

	public ServiceCustomer addServiceCustomer(ServiceCustomer sc) {
		return this.getServiceCustomerDao().saveOrUpdate(sc);
	}
	
	public List<ServiceCustomer> getServiceCustomers(){
		return this.getServiceCustomerDao().getServiceCustomers();
	}

	public ServiceCustomer getServiceCustomerByName(String name) {
		List<ServiceCustomer> scLst = this.getServiceCustomerDao().getServiceCustomerByName(name);
		if(scLst!=null&&scLst.size()>0){
			return scLst.get(0);
		}
		return null;
	}

	public ServiceCustomer getServiceCustomerById(String id) {
		return this.getServiceCustomerDao().getServiceCustomerById(id);
	}

	@Override
	public void deleteServiceCustomer(ServiceCustomer sc) {
		this.getStaffFileDao().updateServiceCustomer(sc.getId());
		this.getServiceCustomerDao().logicDelete(ServiceCustomer.class, sc.getId());
	}

}
